#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
const int N = 100010;
int T, n, m;
LL L, V;
LL d[N], v0[N], a[N];
int in[N], out[N];
LL p[N];

int search_out(int id)
{
    int l = in[id], r = m;
    while (l < r)
    {
        int mid = l + r + 1 >> 1;
        if (-2ll * a[id] * (p[mid] - d[id]) <= v0[id] * v0[id]) l = mid;
        else r = mid - 1;
    }
    return l;
}

int search_left(int id)
{
    int l = in[id], r = out[id];
    if (l == r) return (2ll * a[id] * (p[l] - d[id]) > V * V - v0[id] * v0[id]) ? l : (m + 1);
    while (l < r)
    {
        int mid = l + r >> 1;
        if (2ll * a[id] * (p[mid] - d[id]) > V * V - v0[id] * v0[id]) r = mid;
        else l = mid + 1;
    }
    return l;
}

int search_right(int id)
{
    int l = in[id], r = out[id];
    if (l == r) return (2ll * a[id] * (p[l] - d[id]) > V * V - v0[id] * v0[id]) ? l : (m + 1);
    while (l < r)
    {
        int mid = l + r + 1 >> 1;
        if (2ll * a[id] * (p[mid] - d[id]) > V * V - v0[id] * v0[id]) l = mid;
        else r = mid - 1;
    }
    return l;
}

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    scanf("%d", &T);

    while (T --)
    {
        vector<PII> range;

        scanf("%d%d%lld%lld", &n, &m, &L, &V);
        for (int i = 1; i <= n; i ++) scanf("%lld%lld%lld", &d[i], &v0[i], &a[i]);
        for (int i = 1; i <= m; i ++) scanf("%lld", &p[i]);

        for (int i = 1; i <= n; i ++)
        {
            if (d[i] > p[m]) in[i] = out[i] = m + 1;
            else
            {
                int nxt = lower_bound(p + 1, p + m + 1, d[i]) - p;
                if (a[i] < 0 && -2ll * a[i] * (p[nxt] - d[i]) > v0[i] * v0[i]) in[i] = out[i] = m + 1;
                else
                {
                    in[i] = nxt;
                    if (a[i] >= 0) out[i] = m;
                    else out[i] = search_out(i);
                }
            }
        }

        for (int i = 1; i <= n; i ++)
        {
            if (in[i] > m) continue;
            if (v0[i] <= V)
            {
                if (a[i] <= 0) continue;
                if (2ll * a[i] * (p[out[i]] - d[i]) <= V * V - v0[i] * v0[i]) continue;

                int left = search_left(i);
                if (left > m) continue;
                else range.push_back({left, out[i]});
            }
            else
            {
                if (a[i] >= 0) range.push_back({in[i], out[i]});
                else
                {
                    if (2ll * a[i] * (p[in[i]] - d[i]) <= V * V - v0[i] * v0[i]) continue;
                    int right = search_right(i);
                    if (right > m) continue;
                    else range.push_back({in[i], right});
                }
            }
        }
        printf("%d ", range.size());
        if (range.empty())
        {
            printf("%d\n", m);
            continue;
        }

        sort(range.begin(), range.end());
        int right = range[0].second, res = 0;
        for (int i = 1; i < range.size(); i ++)
            if (range[i].first <= right) right = min(right, range[i].second);
            else
            {
                right = range[i].second;
                res ++;
            }
        res ++;
        printf("%d\n", m - res);
    }

    return 0;
}
